package com.shens.blog.ui;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import com.shens.blog.service.InitInterface;
import com.shens.blog.service.OnBtnClickListener;

public class JInputPanel extends JPanel implements InitInterface {
    private static final long serialVersionUID = 10L;
    JButton btn = null;
    JPanel jPanel1 = null;
    JPanel jPanel2 = null;
    private OnBtnClickListener listener;
    JTextField inputText = null;

    public JInputPanel() {
    }

    public void initView() {
        this.setLayout(new FlowLayout(0));
        this.setSize(844, 50);
        this.setAlignmentY(0.5F);
        JLabel jaLabel = new JLabel("输入文章地址:");
        this.inputText = new JTextField();
        this.inputText.setPreferredSize(new Dimension(650, 50));
        this.btn = new JButton("添加");
        this.add(jaLabel);
        this.add(this.inputText);
        this.add(this.btn);
        this.initListener();
    }

    private void initListener() {
        this.btn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (JInputPanel.this.listener != null) {
                    JInputPanel.this.listener.onBtnClick("addBtn", JInputPanel.this.inputText.getText());
                }

            }
        });
    }

    public void setOnBtnClickListener(OnBtnClickListener listener) {
        this.listener = listener;
    }
}